<template>
	<view :class="['page',{'iphoneX':isIphoneX}]">
		<view v-if="isLogin" class="body">
			<template v-if="detailLoading.default">
				<c-loading :loadingState="loadingState"></c-loading>
			</template>

			<template v-else>
				<template v-if="isAuth">
					<view v-if="detail.status==7&&userInfo.id==detail.user_id" class="fail-tips">
						审核失败：{{detail.comment}}
					</view>
					<view class="info-wrap">
						<image class="info-bg" src="@/static/images/login_bg.png" mode="widthFix"></image>
						<!-- <view class="finish-icon"><image src="@/static/images/gq_icon.png" mode="widthFix"></image></view> -->
						<view class="pro-status">
							<text v-if="detail.status==0" class="btn orange">项目立项</text>
							<text v-if="detail.status==1" class="btn orange">审批中</text>
							<text v-if="detail.status==2" class="btn orange">审批完成</text>
							<text v-if="detail.status==3" class="btn orange">实施中</text>
							<text v-if="detail.status==4" class="btn orange">报告撰写</text>
							<text v-if="detail.status==5" class="btn orange">验收中</text>
							<text v-if="detail.status==6" class="btn green">已完成</text>
							<text v-if="detail.status==7" class="btn red">审批不通过</text>
						</view>
						<view class="content">
							<view class="title">{{detail.project_name}}</view>
							<view v-if="detail.remarks" class="desc">{{detail.remarks}}</view>
							<view class="progress-bar">
								<view class="progress">
									<view class="kd" :style="'width: '+rate.toFixed(0)+'%;'"></view>
								</view>
								<view class="progress-data">{{rate.toFixed(0)}}%</view>
							</view>
							
							<template v-if="detail.status>=2">
								<view class="ft m-b1">
									<view class="status">
										<text>项目经理：</text>
										<template v-if="detail.responsible_name">
											<view class="val">
												<text>{{detail.responsible_name}}</text>
												<navigator v-if="detail.approver==userInfo.id||userInfo.role_id==1||userInfo.department_id==29" url="/package_msg/mailUser/mailUser?scene=2&type=1" hover-class="none" class="iconfont m-l1 f-s30">&#xe75d;</navigator>
											</view>
										</template>

										<navigator v-else-if="detail.responsible_name==''&&(detail.approver==userInfo.id||userInfo.role_id==1||userInfo.department_id==29)" url="/package_msg/mailUser/mailUser?scene=2&type=1" hover-class="none" class="btn orange">指派项目经理</navigator>
										<text v-else>未指派</text>
									</view>

									<view class="status">
										<text>项目组长：</text>
										<template v-if="detail.director_name">
											<view class="val">
												<text>{{detail.director_name}}</text>
												<navigator v-if="detail.responsible==userInfo.id||userInfo.role_id==1||userInfo.department_id==29" :url="'/package_msg/mailUser/mailUser?scene=1&type=1&select_data='+[detail.director].join(',')+'&department_id='+detail.responsible_depid" hover-class="none"
													class="iconfont m-l1 f-s30">&#xe75d;</navigator>
											</view>
										</template>

										<navigator v-else-if="detail.director_name==''&&(detail.responsible==userInfo.id||userInfo.role_id==1||userInfo.department_id==29)"
											:url="'/package_msg/mailUser/mailUser?scene=1&type=1&select_data='+[detail.director].join(',')+'&department_id='+detail.responsible_depid" hover-class="none"
											class="btn orange">指派项目组长</navigator>
										<text v-else>未指派</text>
									</view>
								</view>

								<view class="ft m-b1">

									<view class="status">
										<text>报告撰写人：</text>
										<template v-if="detail.is_report==1">
											<template v-if="detail.report_author_name!=''">
												<view class="val">
													<text>{{detail.report_author_name}}</text>
													<navigator v-if="userInfo.id==21||userInfo.id==1" :url="'/package_msg/mailUser/mailUser?scene=7&select_data='+[detail.report_author,21].join(',')+'&department_id=10&type=1'" hover-class="none" class="iconfont m-l1 f-s30">&#xe75d;</navigator>
												</view>
											</template>

											<navigator v-else-if="(userInfo.id==21||userInfo.id==1)&&detail.report_author_name==''" :url="'/package_msg/mailUser/mailUser?scene=7&select_data='+[detail.report_author,21].join(',')+'&department_id=10&type=1'" hover-class="none"
												class="btn orange">指派报告撰写人</navigator>
											<text v-else>未指派</text>
										</template> 
										<template v-else>
											<view>--</view>
										</template>
										<view v-if="userInfo.id==21" class="check-report-btn" @click="changeReport">
											<view class="item">
												<text v-if="detail.is_report==1" class="iconfont">&#xe637;</text>
												<text v-else class="iconfont">&#xe614;</text>
												<text class="m-l1">有报告</text>
											</view> 
										</view>
									</view>
								</view>
							</template>
							<view class="handle-btn-wrap">
								<view class="left">
									<navigator v-if="detail.status==1&&detail.approver==userInfo.id" url="/package_msg/msg-list/msg-list?type=0" hover-class="none" class="btn orange">去审批</navigator>
									<template v-if="detail.status==3&&rate.toFixed(0)<100">
										<view v-if="detail.warn_level==1" class="btn red"><text>逾期</text></view> <!-- 逾期 -->
										<view v-if="detail.warn_level==2" class="btn green"><text>1级预警</text></view> <!-- 5天预警 -->
										<view v-if="detail.warn_level==3" class="btn yello"><text>2级预警</text></view> <!-- 10天预警 -->

										<template v-if="detail.has_delay==0">
											<view v-if="detail.warn_level<=3&&detail.responsible==userInfo.id" class="btn orange" @click="showPopup('show','isSetDate')">
												<text>申请延期</text>
											</view>
										</template>
										<template v-else>
											<navigator v-if="detail.approver==userInfo.id" url="/package_msg/msg-list/msg-list?type=5" hover-class="none" class="btn orange">延期申请审批</navigator>
											<view v-else class="btn grey">延期申请中</view>
										</template>
									</template>
								</view>
								<view class="right">
									<view v-if="detail.warn_level<=3&&detail.status==3&&userInfo.id==detail.approver" class="btn orange" @click="supervise">督办</view>
									<view v-if="detail.status==1&&detail.user_id==userInfo.id&&detail.approver!=0" class="btn orange" @click="urge">催审</view>
									<!-- 审批失败 重新发送审批 -->
									<template v-if="detail.status==7&&userInfo.id==detail.user_id">
										<view class="btn orange" @click="sendApprove">发送复审</view>
									</template>
									<!-- 初始状态 发送审批 -->
									<template v-if="detail.status==0&&userInfo.id==detail.user_id">
										<navigator :url="'/package_project/created_step-5/created_step-5?scene=1&status='+detail.status+'&id='+detail.id" hover-class="none" class="btn orange">发送审批</navigator>
									</template>

									
									<view v-if="detail.status==3&&rate==100&&detail.responsible==userInfo.id" class="btn orange" @click="showPopup('show','isSendReport')">实施完成</view>
									<view v-if="detail.status==5&&(userInfo.role_id==1)" class="btn orange" @click="reportEnd">项目完成</view> 								

								</view>
							</view>
						</view>
					</view>

					<!-- 项目组成员 -->
					<view v-if="detail.responsible!=0&&isShowUser" class="project_user">
						<view class="label">项目成员</view>
						<view class="list">
							<!-- <view class="item">
								<text>{{detail.responsible_name|substringUsername(detail.responsible_name)}}</text>
							</view>
							<view v-if="detail.director!=0" class="item">

								<text>{{detail.director_name|substringUsername(detail.director_name)}}</text>
							</view> -->
							<view class="item" v-for="(item,index) in userList" :key="index">
								<text>{{item.username|substringUsername(item.username)}}</text>
								<view v-if="userInfo.id==detail.responsible" class="del iconfont" @click="delProUser(index)">&#xe724;</view>
							</view>
							<navigator v-if="userInfo.id==detail.responsible||userInfo.role_id==1||detail.director==userInfo.id" :url="'/package_msg/mailUser/mailUser?scene=3&select_data='+pro_user_id.join(',')+'&type=2'" hover-class="none" class="add m-b2">
								<image src="@/static/images/add.png" mode="widthFix"></image>
							</navigator>
						</view>
					</view>

					<view class="chat-btn m-t2">
						<navigator :url="'/package_customer/customer-window/customer-window?chat_users='+chat_users.join(',')+'&pro_name='+detail.project_name+'&pro_id='+id" hover-class="none">
							<text class="iconfont">&#xe67c;</text>
							<text>即时沟通</text>
						</navigator>
					</view>

					<view class="info-tab">
						<scroll-view scroll-x="true" class="scroll-tab">
							<view :class="['item',{'active':tab=='1'}]" @click="changeTab(1)">
								<view class="name">详情</view>
								<view class="active-line"></view>
							</view>

							<template>
								<!-- 项目助理、超级管理员 可进入 -->
								<view v-if="
									(userInfo.id==detail.responsible||userInfo.id==detail.director)   // 项目经理、项目负责人、项目审批人 
									|| (userInfo.role_id==1)    // 超级管理员
									|| (userInfo.department_id==31 || userInfo.department_id==29 || userInfo.department_id==10)  // 财务部 总经办
								" :class="['item',{'active':tab=='3'}]" @click="changeTab(3)">
									<view class="name">合同</view>
									<view class="active-line"></view>
								</view>


								<!-- 项目助理、超级管理员 实施人员、综合部经理、财务部经理   可进入 -->
								<view v-if="
									(userInfo.id==detail.responsible||userInfo.id==detail.director||userInfo.id==detail.approver)   // 项目经理、项目负责人、项目审批人 
									|| (userInfo.role_id==18 || userInfo.role_id==1)    // 实施人员 、超级管理员
									|| (userInfo.department_id==31 || userInfo.department_id==29 || userInfo.department_id==10)  // 财务部 总经办 综合部
								" :class="['item',{'active':tab=='2'}]" @click="changeTab(2)">
									<view class="name">阶段任务</view>
									<view class="active-line"></view>
								</view>


								<!-- 标书组 、项目经理、超级管理员 可进入 -->
								<view v-if="
									(userInfo.id==detail.responsible)   // 项目经理、项目负责人、项目审批人 
									|| (userInfo.role_id==1)    // 超级管理员
									|| (userInfo.department_id==32 || userInfo.department_id==10 || userInfo.department_id==29 || userInfo.department_id==31)  // 财务部 总经办
								" :class="['item',{'active':tab=='4'}]" @click="changeTab(4)">
									<view class="name">标书</view>
									<view class="active-line"></view>
								</view>

								<!-- 财务 、项目经理、超级管理员 可进入 -->
								<view v-if="  
									 (userInfo.dep_leader==1 || userInfo.role_id==1)    // 超级管理员  部门经理
									|| (userInfo.department_id==31 || userInfo.department_id==29 || userInfo.department_id==10)  // 财务部 总经办 报告撰写人
								" :class="['item',{'active':tab=='5'}]" @click="changeTab(5)">
									<view class="name">回款</view>
									<view class="active-line"></view>
								</view>

								<!-- 财务部、综合部 、项目经理、项目负责人、超级管理员 可进入 -->
								<view v-if=" //detail.status==4 &&  // 状态4
									 detail.is_report=='1'&&((userInfo.id==detail.responsible||userInfo.id==detail.director)   // 项目经理、项目负责人、项目审批人
									 || (userInfo.role_id==18 || userInfo.role_id==1)    // 超级管理员
									 || (userInfo.department_id==31 || userInfo.department_id==29 || userInfo.department_id==10|| userInfo.department_id==47))  // 财务部 总经办 综合部
									" :class="['item',{'active':tab=='6'}]" @click="changeTab(6)">
									<view class="name">验收报告</view>
									<view class="active-line"></view>
								</view>

								<!-- 标书组 、项目经理、超级管理员 可进入 -->
								<view v-if="
									(userInfo.id==detail.responsible)   // 项目经理、项目负责人、项目审批人 
									|| (userInfo.role_id==1)    // 超级管理员
									|| (userInfo.department_id==32 || userInfo.department_id==10 || userInfo.department_id==29 || userInfo.department_id==31)  // 财务部 总经办
								" :class="['item',{'active':tab=='8'}]" @click="changeTab(8)">
									<view class="name">验收意见</view>
									<view class="active-line"></view>
								</view>

								<!-- 综合部 、项目经理、超级管理员 可进入 -->
								<view v-if=" //detail.status==4&&
								   (userInfo.department_id==29||userInfo.department_id==10||userInfo.id==detail.director)   // 总经办 报告撰写小组
								   || (userInfo.dep_leader==1 || userInfo.role_id==1)    // 超级管理员 部门经理
								 " :class="['item',{'active':tab=='7'}]" @click="changeTab(7)">
									<view class="name">材料下载</view>
									<view class="active-line"></view>
								</view>
								 
								<view :class="['item',{'active':tab=='9'}]" @click="changeTab(9)">
									<view class="name">邮寄地址</view>
									<view class="active-line"></view>
								</view>
							</template>
						</scroll-view>
					</view>

					<view class="tab-content">
						<!-- 详情 -->
						<view v-if="tab==1" class="detail">
							<view class="item">
								<view class="hd-title">
									<view class="title">基本信息</view>
								</view>
								<view class="detail-wrap m-b2">
									<view class="detail-item">
										<view class="label">项目名称</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.project_name}}</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">项目编号</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.project_code}}</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">项目省份</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.province_name}}</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">项目类型</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">
													<text>{{detail.project_type_name}}</text>
												</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">签署日期</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.signature_time}}</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">项目时间</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.start_time}}~{{detail.end_time}}</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">项目金额</view>
										<view class="detail-input">
											<view class="content">
												<view class="val f-red f-wb">{{detail.amount}}</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">已回款</view>
										<view class="detail-input">
											<view class="content">
												<view class="val f-red f-wb">{{detail.monback}}</view>
											</view>
										</view>
									</view>
								</view>
							</view>

							<view class="item">
								<view class="hd-title">
									<view class="title">对接人</view>
								</view>
								<view class="detail-wrap m-b2">
									<view class="detail-item">
										<view class="label">姓 名</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.interlocutors}}</view>
											</view>
										</view>
									</view>
									<view v-if="detail.interlocutors_mobile!=0" class="detail-item">
										<view class="label">联系电话</view>
										<view class="detail-input" @click="phoneCall(detail.interlocutors_mobile)">
											<view class="content">
												<view class="val">{{detail.interlocutors_mobile}}</view>
											</view>
											<view class="icon">
												<view class="iconfont f-s34 f-blue">&#xe603;</view>
											</view>
										</view>
									</view>
								</view>
							</view>


							<view class="item">
								<view class="hd-title">
									<view class="title">实施单位</view>
								</view>
								<view class="detail-wrap m-b2">
									<view class="detail-item">
										<view class="label">单位名称</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.implementation_name}}</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">项目经理</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.responsible_name||'未指派'}}</view>
											</view>
										</view>
									</view>
									<view v-if="detail.responsible_name" class="detail-item">
										<view class="label">联系电话</view>
										<view class="detail-input" @click="phoneCall(detail.responsible_mobile)">
											<view class="content">
												<view class="val">{{detail.responsible_mobile}}</view>
											</view>
											<view class="icon">
												<view class="iconfont f-s34 f-blue">&#xe603;</view>
											</view>
										</view>
									</view>
								</view>
							</view>

							<view class="item">
								<view class="hd-title">
									<view class="title">业主单位</view>
								</view>
								<view class="detail-wrap m-b2">
									<view class="detail-item">
										<view class="label">单位名称</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.opposite_part}}</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">联系人</view>
										<view class="detail-input">
											<view class="content">
												<view class="val">{{detail.contacts}}</view>
											</view>
										</view>
									</view>
									<view class="detail-item">
										<view class="label">联系电话</view>
										<view class="detail-input" @click="phoneCall(detail.contact_mobile)">
											<view class="content">
												<view class="val">{{detail.contact_mobile}}</view>
											</view>
											<view class="icon">
												<view class="iconfont f-s34 f-blue">&#xe603;</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>

						<!-- 任务 -->
						<view v-if="tab==2" class="task-list">
							<c-loading v-if="loadingState.default" :loadingState="loadingState"></c-loading>

							<template v-else>
								<template v-if="task.length>0">
									<!-- 项目助理、超级管理员 实施人员  财务经理 可进入 -->
									<template>
										<view class="item" v-for="(item,index) in task" :key="index">
											<view class="title">
												<view class="name f-wb">阶段任务-{{index+1}}</view>
												<view class="status">
													<text v-if="item.status==0">未开始</text>
													<text v-if="item.status==2">进行中</text>
													<text v-if="item.status==1">已完成</text>
													<text v-if="item.status==3">待审核</text>
													<text v-if="item.status==4">被驳回</text>
												</view>
											</view>
											<view class="content">
												<view class="subitem">
													<view class="label">负责人</view>
													<view v-if="detail.director_name" class="val">{{detail.director_name}}</view>
													<view v-else-if="!detail.director_name" class="val">未指派</view>
													<navigator v-else-if="!detail.director_name&&userInfo.dep_loader==1" url="/package_msg/mailUser/mailUser?type=1"
														class="zp-btn">指派负责人</navigator>
												</view>
												<view class="subitem">
													<view class="label">任务描述</view>
													<view class="val">{{item.task_name}}</view>
												</view>
												<view class="subitem">
													<view class="label">优先级</view>
													<view class="val" v-for="(sitem,sindex) in $mock_data.level" :key="sindex">
														<text class="level"
															:class="{'l-1':item.priority==0,'l-2':item.priority==1,'l-3':item.priority==2}"
															v-if="item.priority==sitem.id">{{sitem.name}}</text>
													</view>
												</view>
												<view class="subitem">
													<view class="label">时间</view>
													<view class="val">{{item.start_time}}~{{item.end_time}}</view>
												</view>
												<view class="subitem">
													<view class="label">任务进展</view>
													<view class="val">{{item.desc}}</view>
												</view>
												<view class="btn-wrap">
													<view class="left">
														<template v-if="rate.toFixed(0)<100">
															<view v-if="item.warn_level==1" class="btn red"><text>逾期</text></view> <!-- 逾期 -->
															<view v-if="item.warn_level==2" class="btn green"><text>1级预警</text></view> <!-- 5天预警 -->
															<view v-if="item.warn_level==3" class="btn yello"><text>2级预警</text></view> <!-- 10天预警 -->
															<!-- <view v-if="item.warn_level<=3">申请延期</view> -->
														</template>
													</view>
													<view class="right">
														<navigator
															:url="'/package_project/project-task/project-task?responsible_name='+detail.responsible_name+'&responsible='+detail.responsible+'&director_name='+detail.director_name+'&director='+detail.director+'&id='+item.id+'&type=edit&pro_id='+detail.id+'&files='+JSON.stringify(detail.files)"
															hover-class="none"
															class="btn blue">任务详情</navigator>
														<view v-if="detail.responsible==userInfo.id" class="btn red" @click="delTask(item.id,item.status)">删除</view>
														<view v-if="(item.status==3)&&(detail.responsible==userInfo.id||userInfo.role_id==1)" class="btn red" @click="showPopup('show','isFeadback');currentTask=item">审批</view>
													</view>

												</view>
											</view>
										</view>
									</template>

									<!-- <template v-else>
										<view v-if="detail.duty==userInfo.id" class="item" v-for="(item,index) in task" :key="index">
											<view class="title">
												<view class="name">{{item.task_name}}</view>
												<view class="status">
													<text v-if="item.status==0">未开始</text>
													<text v-if="item.status==2">进行中</text>
													<text v-if="item.status==1">已完成</text>
												</view>
											</view>
											<view class="content">
												<view class="row-2">
													<view class="subitem">
														<view class="label">负责人</view>
														<view v-if="item.duty_name" class="val">{{item.duty_name}}</view>
														<navigator v-else url="/package_msg/mailUser/mailUser?type=1"
															class="zp-btn">指派负责人</navigator>
													</view>
													<view class="subitem">
														<view class="label"></view>
														<view class="val" v-for="(sitem,sindex) in $mock_data.level" :key="sindex">
															<text class="level"
																:class="{'l-1':item.priority==0,'l-2':item.priority==1,'l-3':item.priority==2}"
																v-if="item.priority==sitem.id">{{sitem.name}}</text>
														
														</view>
													</view>
												</view>
												<view class="subitem">
													<view class="label">时间</view>
													<view class="val">{{item.start_time}}~{{item.end_time}}</view>
												</view>
												<view class="subitem">
													<view class="label">任务进展</view>
													<view class="val">{{item.desc}}</view>
												</view>
												<view class="btn-wrap">
													<view class="left">
														<view class="btn red">逾期</view>
													</view>
													
													<view class="right">
														<navigator :url="'/package_project/project-task/project-task?responsible_name='+detail.responsible_name+'&responsible='+detail.responsible+'&director_name='+detail.director_name+'&director='+detail.director+'&id='+item.id+'&type=edit&pro_id='+detail.id+'&files='+JSON.stringify(detail.files)" hover-class="none"
															class="btn blue">任务详情</navigator>  
														<view class="btn red" @click="delTask(item.id,item.status)">删除</view>
													</view>
													
												</view>
											</view>
										</view>
									</template> -->

									<view  class="add-btn">
										<navigator
											:url="'/package_project/project-task/project-task?responsible_name='+detail.responsible_name+'&responsible='+detail.responsible+'&director_name='+detail.director_name+'&director='+detail.director+'&type=add&pro_id='+detail.id+'&files='+JSON.stringify(detail.files)"
											hover-class="none" class="text">添加</navigator>
									</view>
								</template>

								<template v-else>
									<c-empty></c-empty>

									<navigator v-if="(detail.responsible==userInfo.id||detail.user_id==userInfo.id)"
										:url="'/package_project/project-task/project-task?responsible_name='+detail.responsible_name+'&responsible='+detail.responsible+'&director_name='+detail.director_name+'&director='+detail.director+'&type=add&pro_id='+detail.id+'&files='+JSON.stringify(detail.files)"
										hover-class="none" class="empty-btn">添加阶段任务</navigator>
								</template>
							</template>
						</view>

						<!-- 合同 -->
						<view v-if="tab==3" class="download-wrap">
							<c-uploadFile type='1' :pro_id="id" task_id="" v-if="hackreset"></c-uploadFile>
						</view>

						<!-- 标书 -->
						<view v-if="tab==4" class="download-wrap">
							<c-uploadFile type='2' :pro_id="id" task_id="" v-if="hackreset"></c-uploadFile>
						</view>

						<!-- 回款 -->
						<view v-if="tab==5" class="back-money-play">
							<c-loading v-if="loadingState.default" :loadingState="loadingState"></c-loading>

							<template v-else>
								<template v-if="promonbackList.length>0">
									<view class="item" v-for="(item,index) in promonbackList" :key="index">
										<view class="title">
											<view class="name">{{index+1}}期回款</view>
											<view class="status">{{item.status==0?'未回款':'已回款'}}</view>
										</view>
										<view class="content">
											<view class="row-2">
												<view class="subitem">
													<view class="label">回款金额</view>
													<view class="val f-red f-wb">{{item.amount}}</view>
												</view>
												<view class="subitem">
													<view class="label">回款比例</view>
													<view class="val">{{Number(item.point).toFixed(0)}}%</view>
												</view>
											</view>
											<view class="subitem">
												<view class="label">回款时间</view>
												<view class="val">{{item.btime}}</view>
											</view>
											<view class="subitem">
												<view class="label">备注</view>
												<view class="val">{{item.desc}}</view>
											</view>
											<view class="btn-wrap">
												<navigator :url="'/package_project/project-back-money/project-back-money?id='+item.id+'&type=edit&pro_id='+detail.id"
													hover-class="none" class="btn blue">回款详情</navigator>
												<!-- <view v-if="item.status==1" class="btn orange">查看发票</view> -->
												<!-- <view v-else class="btn orange">上传发票/回执</view> -->
												<view class="btn red" @click="delBackMoney(item.id)">删除</view>
											</view>
										</view>
									</view>
									<view v-if="userInfo.dep_leader==1" class="add-btn">
										<navigator :url="'/package_project/project-back-money/project-back-money?type=add&pro_id='+detail.id" hover-class="none"
											class="text">添加回款</navigator>
									</view>
								</template>
								<template v-else>
									<c-empty></c-empty>
									<navigator :url="'/package_project/project-back-money/project-back-money?type=add&pro_id='+detail.id"
										hover-class="none" class="empty-btn">添加回款</navigator>
								</template>


							</template>
						</view>

						<!-- 验收报告 -->
						<view v-if="tab==6" class="download-wrap">
							<c-uploadFile type='7' :pro_id="id" task_id="" v-if="hackreset"></c-uploadFile>
							<view v-if="detail.ys_status==0" class="finish-btn m-t2" @click="reportEnd">验收报告上传完成</view>
						</view>
						
						<!-- 验收意见 -->
						<view v-if="tab==8" class="download-wrap">
							<c-uploadFile type='10' :pro_id="id" task_id="" v-if="hackreset"></c-uploadFile>
							<view v-if="detail.yj_status==0" class="finish-btn m-t2" @click="yanshouEnd">验收意见上传完成</view>
						</view>
						
						<!-- 材料下载 -->
						<view v-if="tab==7" class="download-wrap">
							<template v-if="loadingState.default">
								<c-loading :loadingState="loadingState"></c-loading>
							</template>
							<template v-else>
								<view v-if="files.length>0" class="list files-list">
									<view class="item" v-for="(item,index) in files" :key="index">
										<view class="left" @click="previewFiles(index)">
											<view class="file-icon">
												<image v-if="$checkFileType(item.file_name)==3" src="@/static/images/pdf.png" mode="widthFix"></image>
												<image v-if="$checkFileType(item.file_name)==1" src="@/static/images/word.png" mode="widthFix"></image>
												<image v-if="$checkFileType(item.file_name)==2" src="@/static/images/excel.png" mode="widthFix"></image>
												<image v-if="$checkFileType(item.file_name)==4" src="@/static/images/image.png" mode="widthFix"></image>
											</view>
											<view class="name">
												<view class="title split">{{item.file_name}}</view>
												<view class="info">
													<text>{{item.create_time}}</text>
													<text v-if="item.type==1">合同</text>
													<text v-if="item.type==2">标书</text>
													<text v-if="item.type==3">图片</text>
													<text v-if="item.type==4">其他</text>
													<text v-if="item.type==5">财务</text>
													<text v-if="item.type==6">业务</text>
													<text v-if="item.type==7">验收报告</text>
												</view>
											</view>
										</view>
										<view class="download-icon" @click="downLoad(index)">
											<image src="@/static/images/download_icon.png" mode="widthFix"></image>
										</view>
						
										<!-- <view class="download-tips">
												文件保存路径【文件管理】-> 【我的手机】->【瑞丰生物】</view> -->
									</view>
								</view>
								<c-empty v-else></c-empty>
							</template>
						</view>
						
						<!-- 邮寄地址 -->
						<view v-if="tab==9" class="mail-info"> 
							<view class="">
								<view class="f-s30 m-b2 f-wb">请各项目成员按以下人员邮寄相关资料</view> 
								<view class="m-b4 f-s30">
									<view class="m-b2">项目合同及验收意见</view>
									<view class="m-b2"><text class="m-r2">收件人：标书部</text><text>联系方式：13632109449</text></view>
									<view><text>收件地址：</text><text>广州市增城区朱村大道西科源三街4号16栋瑞丰科技大楼</text></view>
								</view>
								<view class="m-b4 f-s30">
									<view class="m-b2">货物验收单及签收单</view>
									<view class="m-b2"><text class="m-r2">收件人：财务部</text><text>联系方式：13808898940</text></view>
									<view><text>收件地址：</text><text>广州市黄埔区科学大道48号绿地中央广场E栋2605</text></view>
								</view>
								<view class="m-b4 f-s30">
									<view class="m-b2">培训签到表</view>
									<view class="m-b2"><text class="m-r2">收件人：知识产权部</text><text>联系方式：15920343894</text></view>
									<view><text>收件地址：</text><text>广州市黄埔区科学大道48号绿地中央广场E栋2605</text></view>
								</view>
								<view class="m-b4 f-s30">注:同一地址请邮寄一份标注好给谁的文件!</view>
								
							</view>
						</view>
										
					
					</view>

					
				</template>
				
				<template v-else>
					<c-empty :msg="errorMsg"></c-empty>
				</template>
			</template>
		</view>

		<!-- <view v-if="scene==1&&detail.status==1" class="footer">
			<view class="fix-wrap created-btn-wrap">
				<navigator :delta="1" open-type="navigateBack" hover-class="none" class="btn submit-btn">返回审批</navigator>
			</view>
		</view>		 -->
	 
		<view v-if="flag.isFullPage" class="full-fix-page">
			<!-- 申请延期 -->
			<view v-if="flag.isSetDate" class="popup-wrap a-fadein">
				<view class="popup-type-model">
					<view class="close-btn iconfont f-s44" @click="showPopup('hide')">&#xeb6a;</view>
					<view class="popup-body">
						<view class="title">申请延期</view>
						<view class="content">
							<view class="inp-bar m-b2">
								<view class="label">延期原因</view>
								<textarea class="inp-textarea" v-model="setDate.content" placeholder="输入延期原因"></textarea>
							</view>
							<view class="inp-bar m-b2">
								<view class="label">合同结束日期</view>
								<input type="text" class="inp-input f-grey" disabled v-model="detail.end_time" placeholder="输入新名称">
							</view>
							<view class="inp-bar m-b2">
								<view class="label">延期日期</view>
								<picker class="inp-picker" mode="date" @change="setNewEndTime">
									<input type="text" class="inp-input" disabled v-model="setDate.new_end_time" placeholder="选择延期日期">
									<view class="iconfont">&#xec35;</view>
								</picker>
							</view>
							<view class="comfirm-btn" @click="applyDate">确定</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 材料反馈 -->
			<view v-if="flag.isFeadback" class="popup-wrap a-fadein">
				<!-- <view class="popup-type-model">
					<view class="close-btn iconfont f-s44" @click="showPopup('hide')">&#xeb6a;</view>
					<view class="popup-body">
						<view class="title">材料反馈</view>
						<view class="content">
							<view class="inp-bar m-b2">
								<view class="label">项目经理/项目组长</view>
								<view class="inp-input f-grey">{{detail.responsible_name?detail.responsible_name:''}} {{detail.director_name?detail.director_name:''}}</view>
							</view>
							<view class="inp-bar m-b2">
								<view class="label">反馈意见</view>
								<textarea class="inp-textarea" v-model="feacback" placeholder="输入反馈意见"></textarea>
							</view>
							<view class="comfirm-btn" @click="sendFeadBack">确定</view>
						</view>
					</view>
				</view> -->
				<view class="popup-type-model">
					<view class="close-btn iconfont f-s44" @click="showPopup('hide')">&#xeb6a;</view>
					<view class="popup-body">
						<view class="title">审批</view>
						<view class="content">
							<!-- <view class="inp-bar m-b2">
								<view class="label">任务名称</view>
								<view class="inp-input f-grey">{{currentTask.task_name}}</view>
							</view> -->
							<!-- <view class="inp-bar m-b2">
								<view class="label">任务状态</view>
								<view class="inp-input f-grey"> 
									<text v-if="currentTask.status==3">待审核</text>
									<text v-if="currentTask.status==4">被驳回</text>
								</view>
							</view> -->
							<view class="inp-bar m-b2">
								<view class="label">驳回意见</view>
								<textarea class="inp-textarea" v-model="feacback" placeholder="输入反馈意见"></textarea>
							</view>
							<view class="sp-btn-bar">
								<view class="btn comfirm-btn" @click="sendFeadBack(1)">同意</view>
								<view class="btn comfirm-btn cancle-btn" @click="sendFeadBack(4)">驳回</view>
							</view>							
						</view>
					</view>
				</view>
			</view>

			<!-- 通知撰写报告 -->
			<view v-if="flag.isSendReport" class="popup-wrap a-fadein">
				<view class="popup-type-model">
					<view class="close-btn iconfont f-s44" @click="showPopup('hide')">&#xeb6a;</view>
					<view class="popup-body">
						<view class="title">通知撰写报告</view>
						<view class="content">
							<view class="inp-bar m-b2">
								<view class="label">需要完成时间</view>
								<picker class="inp-picker" mode="date" @change="setReportDayTime">
									<input type="text" class="inp-input" disabled v-model="reportDay" placeholder="完成时间">
									<view class="iconfont">&#xec35;</view>
								</picker>
							</view>
							<view class="comfirm-btn" @click="reportMsg">确定</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		 
	</view> 
</template>

<script>
	import {
		dateFormat,
		previewImage
	} from '@/common/util.js'  
	export default { 
		data() {
			return { 
				isIphoneX: getApp().globalData.isIphoneX,
				isLogin: false,
				userInfo: uni.getStorageSync('userInfo'),
				id: '',
				tab: 1,
				scene: '', // 场景  1 审核浏览
				detail: {},
				files: [],
				contract: [],
				biding: [],
				report: [],
				userList: [],
				pro_user_id: [],
				task: [],
				rate: 0, // 项目进度
				promonbackList: [],
				loadingState: {
					default: true
				},
				detailLoading: {
					default: true
				},
				hackreset: false,
				flag: {
					isFullPage: false,
					isSetDate: false,
					isSendReport: false,
					isFeadback: false,

				},
				setDate: {
					new_end_time: '',
					content: ''
				},
				reportDay: '',
				isStop: true,
				isShowUser: false,
				chat_users: [19, 28, 21],
				feacback: '',
				isAuth:false,
				currentTask:{},
				errorMsg:''

			}
		},
		async onLoad(params) {
			this.isLogin = await this.$loginState('check');
			// 项目类型
			this.id = params.id;
			if (params.scene) {
				this.scene = params.scene;
			}

			if (this.isLogin) {
				this.getDetail();
				this.getTaskRate();
			}

		},
		filters: {
			substringUsername(val) {
				if (val) return val.substring(val.length - 2);
			},
		},
		methods: {
			changeReport(){ 
				this.$api.user_api.projectisreport({
					id:this.id,
					is_report:this.detail.is_report==1?2:1
				}).then(res=>{ 
					if(res.data.code==200){
						uni.showToast({
							icon:'none',
							title:res.data.msg,
							mask:true,
							duration:2000
						})
						this.detail.is_report=res.data.pdata.is_report;
					}
				})
			},
			changeTab(val) {
				this.tab = val;
				this.loadingState.default = true;
				if (val == 2) {
					this.task = [];
					this.getTaskList();
				}
				if (val == 3 || val == 4 || val == 6 || val == 8) {
					this.hackreset = false
					this.$nextTick(() => {
						this.hackreset = true;
					})
				}
				if (val == 5) {
					this.promonbackList = [];
					this.getPromonbackList();
				}
				if (val == 7) {
					// this.fileLoading.default=true;
					this.getProFiles();
				}

			},

			// 获取项目成员
			async getProUser() {
				let res = await this.$api.user_api.getProUser({
					id: this.id
				}) 
				if (res.data.code == 200) {
					this.isShowUser = true;
					this.userList=res.data.data;
					res.data.data.forEach(item => {
						if (item.user_id != this.detail.responsible && item.user_id != this.detail.director && item.user_id != this.detail.user_id && item.user_id != this.detail.approver) {							 
							if (this.pro_user_id.indexOf(item.user_id) == -1) {
								this.pro_user_id.push(item.user_id);
							}
						}
						if (this.chat_users.indexOf(item.user_id) == -1) {
							this.chat_users.push(item.user_id);
						}
					})
				}
			},

			async sendFeadBack(type) { 
				if(type==4){
					if (this.feacback == '') {
						this.$showToast({
							icon: 'none',
							title: '请输入驳回意见'
						})
						return
					}
				}
				let res = await this.$api.user_api.taskchangestatus({
					id: this.currentTask.id,
					status: type,
					remark: this.feacback, 
				}); 
				if(res.data.code==200){
					this.showPopup('hide');
					this.$store.commit('TASK_LIST_UPDATE',1);   // 更新任务列表
				}
				console.log(res) 
				
			},

			// 删除项目成员
			delProUser(idx) {
				let _this = this;
				uni.showModal({
					content: '确定将该成员移出项目吗？',
					mask: true,
					async success(res) {
						if (res.confirm) {
							let del_res = await _this.$api.user_api.delProUser({
								project_id: _this.id,
								user_id: _this.userList[idx].user_id
							})
							if (del_res.data.code == 200) {
								_this.$showToast({
									icon: 'success',
									title: '移除成功',
								}).then(async () => {
									let res = await _this.$api.user_api.addMsg({
										project_id: _this.id,
										task_id: '',
										content: '【' + _this.detail.responsible_name + '】将您移出了《' + _this.detail.project_name + '》项目，请知悉！',
										user_id: _this.userList[idx].user_id,
										type: 1,
										content_type: 4,
										title: '关于移出《' + _this.detail.project_name + '》项目的消息'
									});
									let del_id = _this.userList[idx].user_id;
									_this.userList.splice(idx, 1);
									let index = _this.pro_user_id.indexOf(del_id);
									_this.pro_user_id.splice(index, 1);
								})
							}
						}
					}
				})
			},

			// 项目详情
			async getDetail() {
				let res = await this.$api.user_api.projectInfo({
					id: this.id
				}) 
				console.log(res)
				if (res.data.code == 200) {
					this.detailLoading.default = false;
					this.isAuth=true;
					if (res.data.data.responsible) {
						this.pro_user_id.push(res.data.data.responsible);
					}
					if (res.data.data.director) {
						this.pro_user_id.push(res.data.data.director);
					}

					let date = new Date();
					let nowTime = date.getTime();
					let diff_time = res.data.data.end_time * 1000 - nowTime;
					let day = diff_time / (24 * 60 * 60 * 1000);
					if (day <= 10 && day > 5) {
						// 2级预警
						res.data.data.warn_level = 3;
					} else if (day <= 5 && day > 0) {
						// 1级预警
						res.data.data.warn_level = 2;
					} else if (day <= 0) {
						// 逾期
						res.data.data.warn_level = 1;
					}
					res.data.data.amount = this.$moneyToFormat(res.data.data.amount);
					res.data.data.monback = this.$moneyToFormat(res.data.data.monback);
					res.data.data.end_time = dateFormat(res.data.data.end_time * 1000, 'YYYY-MM-DD');
					res.data.data.start_time = dateFormat(res.data.data.start_time * 1000, 'YYYY-MM-DD');
					res.data.data.signature_time = dateFormat(res.data.data.signature_time * 1000, 'YYYY-MM-DD');
					this.detail = res.data.data;


					this.getProUser(); // 获取项目成员

				}else{
					console.log(123)
					this.detailLoading.default = false;
					this.isAuth=false;
					this.errorMsg=res.data.msg;
				}
			},

			// 获取文件
			async getProFiles(type) {
				let res = await this.$api.user_api.getProFiles({
					project_id: this.id,
					type: ''
				})
				if (res.data.code == 200) {
					this.loadingState.default = false;
					this.files = res.data.data;
				}

			},

			// 获取任务进度
			async getTaskRate() {
				let res = await this.$api.task_api.getTaskRate({
					pid: this.id
				})
				if (res.data.code == 200) {
					this.rate = res.data.data;
					console.log(this.rate)
					// if (this.rate == 100) {
					// 	// 更新项目状态
					// 	let update_status = await this.$api.project_api.updateProjectStatus({
					// 		id: this.detail.id,
					// 		status: '4',
					// 		content: this.detail.responsible_name + '阶段任务已完成',
					// 	})
					// 	this.$store.commit('PROJECT_LIST_UPDATE', 1);
					// }
				}
			},

			// 任务列表
			async getTaskList() {
				let res = await this.$api.task_api.getTaskList({
					project_id: this.id,
					page: 1,
					limit: 2000,
					keyword: '', //任务编号  名称 
					status: '-1'
				});
				console.log('res.data.data.list',res.data.data.list)
				if (res.data.code == 200) {
					this.loadingState.default = false;
					res.data.data.list.forEach(item => {
						let diff_time = new Date(item.end_time).getTime() - new Date().getTime();
						let day = diff_time / (24 * 60 * 60 * 1000);
						if (day <= 10 && day > 5) {
							// 2级预警
							item.warn_level = 3;
						} else if (day <= 5 && day > 0) {
							// 1级预警
							item.warn_level = 2;
						} else if (day <= 0) {
							// 逾期
							item.warn_level = 1;
						}
					})
					this.task = res.data.data.list;
				}
			},

			// 回款计划列表
			async getPromonbackList() {
				let res = await this.$api.user_api.promonbackList({
					page: 1,
					limit: 2000,
					pro_id: this.id
				});
				if (res.data.code == 200) {
					this.loadingState.default = false;
					res.data.data.list.forEach(item => {
						item.amount = this.$moneyToFormat(item.amount)
					})
					this.promonbackList = res.data.data.list;
				}
			},

			// 删除任务
			async delTask(id, status) {
				let _this = this;
				if (status == 1) {
					uni.showModal({
						content: '该任务正在进行中，不能删除',
					})
					return
				} else {
					uni.showModal({
						content: '确定删除该任务阶段吗？',
						async success(res) {
							if (res.confirm) {
								let del_res = await _this.$api.task_api.delTask({
									id: id
								});
								console.log('del_res',del_res)
								if (del_res.data.code == 200) {
									_this.$showToast({
										icon: 'success',
										title: '删除成功',
										duration: 1000,
									}).then(() => {
										setTimeout(() => {
											_this.$store.commit('TASK_LIST_UPDATE', 1); // 更新任务列表
										}, 1000)
									})
								} else {
									_this.$showToast({
										icon: 'error',
										title: del_res.data.msg
									})
								}
							}
						}
					})
				}
			},

			// 删除回款计划
			delBackMoney(id) {
				let _this = this;
				uni.showModal({
					content: '确定删除该数据吗？',
					async success(res) {
						if (res.confirm) {
							let del_res = await _this.$api.user_api.promonbackDel({
								id: id
							})
							if (del_res.data.code == 200) {
								_this.$showToast({
									icon: 'success',
									title: '删除成功',
									duration: 1000,
								}).then(() => {
									setTimeout(() => {
										_this.$store.commit('BACK_MONEY_LIST_UPDATE', 1); // 更新回款计划列表
									}, 1000)
								})
							} else {
								_this.$showToast({
									icon: 'error',
									title: del_res.data.msg
								})
							}
						}
					}
				})


			},

			// 发送复审
			async sendApprove() {
				let res = await this.$api.user_api.addMsg({
					project_id: this.detail.id,
					task_id: '',
					content: '【' + this.detail.user_name + '】重新提交了《' + this.detail.project_name + '》项目复审，请您尽快到【项目审批消息】中完成审批！',
					user_id: this.detail.approver,
					type: 1,
					content_type: 0,
					title: '关于《' + this.detail.project_name + '》项目复审批的消息'
				});
				// 更新项目状态
				let update_status = await this.$api.project_api.updateProjectStatus({
					id: this.detail.id,
					status: '1',
					content: '提交给【' + this.detail.approver_name + '】复审',
				})
				if (update_status.data.code == 200) {
					this.$showToast({
						icon: 'success',
						title: '发送审批成功'
					})
					this.$store.commit('PROJECT_LIST_UPDATE', 1);
				}
			},

			// 催审
			async urge() {
				let res = await this.$api.user_api.addMsg({
					project_id: this.detail.id,
					task_id: '',
					content: '《' + this.detail.project_name + '》项目，请您尽快到【项目审批消息】中完成审批！',
					user_id: this.detail.approver,
					type: 1,
					content_type: 4,
					title: '关于《' + this.detail.project_name + '》项目催促审批的消息'
				});
				if (res.data.code == 200) {
					this.$showToast({
						title: '已向【' + this.detail.approver_name + '】发起催审！'
					})
				}
			},

			// 督办
			async supervise() {
				let res = await this.$api.user_api.addMsg({
					project_id: this.detail.id,
					task_id: '',
					content: '《' + this.detail.project_name + '》项目，即将到合同日期，请加快项目的实施进度，按时完成项目',
					user_id: this.detail.responsible,
					type: 1,
					content_type: 1,
					title: '关于《' + this.detail.project_name + '》项目督办的消息'
				});
				if (res.data.code == 200) {
					this.$showToast({
						icon: 'success',
						title: '督办成功'
					})
				}
			},

			// 报告撰写日期选择
			setReportDayTime(e) {
				this.reportDay = e.target.value;
			},

			// 通知撰写报告
			async reportMsg() {
				uni.showLoading({
					mask: true,
					title: '发送中...'
				})
				let res = await this.$api.user_api.addMsg({
					project_id: this.detail.id,
					task_id: '',
					content: '《' + this.detail.project_name + '》项目，各项任务已完成，并上传相关材料，【' + this.detail.responsible_name + '】指派您开展报告撰写工作！',
					user_id: '21',
					type: 1,
					content_type: 3,
					delay_time: this.reportDay,
					title: '关于《' + this.detail.project_name + '》项目报告撰写的消息'
				});
				if (res.data.code == 200) {
					this.showPopup('hide');
					uni.hideLoading();
					let update_status = await this.$api.project_api.updateProjectStatus({
						id: this.detail.id,
						status: '4',
						content: this.detail.responsible_name + '完成任务',
					})
					if (update_status.data.code == 200) {
						this.detail.status = 4;
						this.$store.commit('PROJECT_LIST_UPDATE', 1);
					}
					this.$showToast({
						icon: 'success',
						title: '发送成功'
					})
				} else {
					this.$showToast({
						icon: 'success',
						title: '发送失败'
					})
				}
			},

			// 项目报告完成
			async reportEnd() {
				let _this = this;
				let files = this.detail.files;
				let files_type_index = files.findIndex(item => item.type == 7);
				if (files_type_index < 0) {
					this.$showToast({
						icon: 'error',
						title: '未上传任何文件'
					})
					return
				}
				uni.showModal({
					content: '该项目相关报告已经完成，确定报告都上传完了吗？',
					mask: 'true',
					async success(m_res) {
						if (m_res.confirm) {
							let res = await _this.$api.user_api.addMsg({
								project_id: _this.detail.id,
								task_id: '',
								content: '《' + _this.detail.project_name + '》项目，各验收已完成，并已上传相关材料！',
								user_id: '21_19_20_' + _this.detail.director + '_' + _this.detail.responsible + '_' + _this.detail.report_author,
								type: 1,
								content_type: 4,
								delay_time: _this.reportDay,
								title: '关于《' + _this.detail.project_name + '》项目验收报告上传完成的消息'
							});
							if (res.data.code == 200) {
								_this.showPopup('hide');
								uni.hideLoading();
								// let update_status = await _this.$api.project_api.updateProjectStatus({
								// 	id:_this.detail.id,
								// 	status: '6',
								// 	content: _this.detail.responsible_name+'项目完成',
								// }) 
								let update_status = await _this.$api.project_api.Projectchangeys({
									id: _this.detail.id,
									ys_status: 1,
								})
								console.log('update_status', update_status)
								if (update_status.data.code == 200) {
									_this.detail.ys_status = 1;
									_this.$store.commit('PROJECT_LIST_UPDATE', 1);
									_this.$showToast({
										icon: 'success',
										title: '验收报告完成'
									})
								}
							} else {
								_this.$showToast({
									icon: 'success',
									title: '发送失败'
								})
							}
						}
					}
				})
			},

			// 验收意见上传完成
			async yanshouEnd() {
				let _this = this;
				let files = this.detail.files;
				let files_type_index = files.findIndex(item => item.type == 10);
				if (files_type_index < 0) {
					this.$showToast({
						icon: 'error',
						title: '未上传任何文件'
					})
					return
				}
				uni.showModal({
					content: '该项目相关验收意见已经完成，确定验收意见都上传完了吗？',
					mask: 'true',
					async success(m_res) {
						if (m_res.confirm) {
							let res = await _this.$api.user_api.addMsg({
								project_id: _this.detail.id,
								task_id: '',
								content: '《' + _this.detail.project_name + '》项目，已上传项目验收意见，并已上传相关材料！',
								user_id: '21_19_20_' + _this.detail.director + '_' + _this.detail.responsible + '_' + _this.detail.report_author,
								type: 1,
								content_type: 4,
								delay_time: _this.reportDay,
								title: '关于《' + _this.detail.project_name + '》项目验收意见上传完成的消息'
							});
							if (res.data.code == 200) {
								_this.showPopup('hide');
								uni.hideLoading();
								// let update_status = await _this.$api.project_api.updateProjectStatus({
								// 	id:_this.detail.id,
								// 	status: '6',
								// 	content: _this.detail.responsible_name+'项目完成',
								// }) 
								let update_status = await _this.$api.project_api.Projectchangeyj({
									id: _this.detail.id,
									yj_status: 1,
								})
								console.log('update_status', update_status)
								if (update_status.data.code == 200) {
									_this.detail.yj_status = 1;
									_this.$store.commit('PROJECT_LIST_UPDATE', 1);
									_this.$showToast({
										icon: 'success',
										title: '验收意见完成'
									})
								}

							} else {
								_this.$showToast({
									icon: 'success',
									title: '发送失败'
								})
							}
						}
					}
				})
			},


			// 打开弹窗
			showPopup: function(t, n) {
				if (t == 'show') {
					this.flag.isFullPage = true;
					this.flag[n] = true;
				} else if (t == 'hide') {
					for (let i in this.flag) {
						this.flag[i] = false;
					}
				}
			},

			// 打电话
			phoneCall(phone) {
				uni.makePhoneCall({
					phoneNumber: phone
				});
			},

			// 设置新结束日期
			setNewEndTime(e) {
				this.setDate.new_end_time = e.target.value;
			},

			// 申请延期
			async applyDate() {
				if (this.setDate.content == '') {
					this.$showToast({
						title: '请输入申请延期原因'
					})
					return
				}
				if (this.setDate.new_end_time == '') {
					this.$showToast({
						title: '请选择延期日期'
					})
					return
				}

				if (this.isStop) {
					this.isStop = false;
					// 发送延期申请消息
					let sp_res = await this.$api.user_api.addMsg({
						project_id: this.id,
						task_id: '',
						content: '由于' + this.setDate.content + '，【' + this.detail.responsible_name + '】申请《' + this.detail.project_name + '》项目延期至' + this.setDate.new_end_time + '，请您审批！',
						user_id: this.detail.approver,
						type: 1,
						content_type: 5,
						delay_time: this.setDate.new_end_time,
						title: '关于《' + this.detail.project_name + '》项目申请延期的消息'
					});
					if (sp_res.data.code == 200) {
						this.detail.has_delay = 1;
						this.showPopup('hide');
						this.$showToast({
							icon: 'success',
							title: '发送申请成功'
						})
					}
				}
			},

			// 预览文件
			previewFiles(idx) {
				if (this.$checkFileType(this.files[idx].file_name) == 4) {
					let path = `https://xmjzapi.isca.cn/api/image/image?task_id=${this.files[idx].task_id}&project_id=${this.id}&img=${this.files[idx].file_name}`;
					previewImage({
						data: [path],
						index: 0,
					})
				} else {
					uni.navigateTo({
						url: `/pages/webview/webview?type=${this.$checkFileType(this.files[idx].file_name)}&task_id=${this.files[idx].task_id}&project_id=${this.id}&name=${this.files[idx].file_name}`
					})

				}
			},

			// 下载文件
			downLoad(idx) {
				let _this = this;
				let path = `https://xmjzapi.isca.cn:1443/api/file/load?project_id=${this.id}&name=${this.files[idx].file_name}`
				uni.showLoading({
					title: "下载中...",
					mask: true
				})
				let dtask = plus.downloader.createDownload(path, {
					filename: "file://storage/emulated/0/瑞丰生物/" + this.files[idx].file_name //利用保存路径，实现下载文件的重命名
				}, (d, status) => {
					//d为下载的文件对象 
					if (status == 200) {
						uni.hideLoading();
						uni.showModal({
							content: '文件保存成功，查看路径【文件管理】-> 【我的手机】->【瑞丰生物】',
							mask: true,
							showCancel: false,
							confirmText: '我知道了'
						})
						//下载成功,d.filename是文件在保存在本地的相对路径，使用下面的API可转为平台绝对路径
						let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
					} else {
						//下载失败
						uni.hideLoading();
						plus.downloader.clear(); //清除下载任务
						uni.showToast({
							icon: 'none',
							mask: true,
							title: '下载失败，请稍后重试',
						});
					}
				})
				dtask.start();
			}

		},

		computed: {
			// 负责人
			duty_state() {
				return this.$store.state.duty_state
			},

			// 项目经理
			project_manage_state() {
				return this.$store.state.project_manage_state
			},

			// 项目成员
			project_user_update() {
				return this.$store.state.pro_user
			},

			// 任务列表
			task_list_update() {
				return this.$store.state.task_list_state
			},

			// 回款计划列表
			promonback_list_update() {
				return this.$store.state.back_money_state;
			},

			// status 审批状态
			status_update() {
				return this.$store.state.project_list
			},

			// 报告撰写人更新
			report_user_update() {
				return this.$store.state.report_user
			}

		},
		watch: {
			async duty_state(newer, older) { 
				if (newer.id != older.id) { 
					if (this.detail.director_name) {
						this.detail.director_name=newer.username;
						this.detail.director=newer.id;
						let dsp_res = await this.$api.user_api.addMsg({
							project_id: this.id,
							task_id: '',
							content: '【' + this.detail.responsible_name + '】取消【' + this.detail.director_name + '】为《' + this.detail.project_name + '》项目负责人，请知悉！',
							user_id: this.detail.director,
							type: 1,
							content_type: 3,
							title: '《' + this.detail.project_name + '》项目取消您为项目负责人的通知'
						});
						
						this.userList = [];
						this.pro_user_id = [];
						 // 获取项目成员
						
						let d_res = await this.$api.user_api.deldirector({
							project_id: this.id
						})
						if (d_res.data.code == 200) {
							// 发送消息 负责人
							let res = await this.$api.user_api.addDirector({
								project_id: this.id,
								user_id: newer.id
							})
							if (res.data.code == 200) {								
								this.getProUser();
								// 发送消息 负责人
								let sp_res = await this.$api.user_api.addMsg({
									project_id: this.id,
									task_id: '',
									content: '【' + this.detail.responsible_name + '】指派【' + newer.username + '】为《' + this.detail.project_name + '》项目负责人，请尽快组织开展项目实施！',
									user_id: newer.id,
									type: 1,
									content_type: 3,
									title: '《' + this.detail.project_name + '》项目指派您为项目负责人的通知'
								}); 
							}
						}
					} else { 
						// 发送消息 负责人
						let sp_res = await this.$api.user_api.addMsg({
							project_id: this.id,
							task_id: '',
							content: '【' + this.detail.responsible_name + '】指派【' + newer.username + '】为《' + this.detail.project_name + '》项目负责人，请尽快组织开展项目实施！',
							user_id: newer.id,
							type: 1,
							content_type: 3,
							title: '《' + this.detail.project_name + '》项目指派您为项目负责人的通知'
						});
						this.detail.director_name=newer.username;
						this.detail.director=newer.id;
						this.userList = [];
						this.pro_user_id = [];
						
						
						let res = await this.$api.user_api.addDirector({
							project_id: this.id,
							user_id: newer.id
						})
						console.log(res)
						if (res.data.code == 200) { 
							this.getProUser(); // 获取项目成员
						}
					}




				}
			},

			async report_user_update(newer, older) {
				let user_ids = [];
				if (newer.id != older.id) {
					this.detail.report_author_name = newer.username;
					this.detail.report_author = newer.id;
					this.pro_user_id = [];
					this.userList = [];
					this.getProUser();
					user_ids.push(newer.id);
					let res = await this.$api.user_api.addMsg({
						project_id: this.id,
						task_id: '',
						content: '【林小军】指派您负责《' + this.detail.project_name + '》项目的报告撰写，请您及时了解跟进项目进度状况，撰写报告！',
						user_id: user_ids.join('_'),
						type: 1,
						content_type: 3,
						title: '关于《' + this.detail.project_name + '》指派您为项目报告撰写人的通知'
					});

					let a_res = await this.$api.user_api.addreportauthor({
						project_id: this.id,
						user_id: newer.id
					})
					if (a_res.data.code == 200) {						
						
					}
				}
			},

			async project_user_update(newer, older) {
				let user_ids = [];
				if (newer != older) {
					newer.forEach(item => {
						user_ids.push(item.id);
					})
					let add_res = await this.$api.user_api.addProUser({
						project_id: this.id,
						user_id: user_ids.join(',')
					})
					if (add_res.data.code == 200) {
						this.$showToast({
							icon: 'success',
							title: '添加成功',
						}).then(async () => {
							this.getProUser();
							this.pro_user_id = user_ids;
							this.chat_users = user_ids;
							let res = await this.$api.user_api.addMsg({
								project_id: this.id,
								task_id: '',
								content: '【' + this.detail.responsible_name + '】邀请您参与《' + this.detail.project_name + '》项目，请您尽快开展项目任务工作！',
								user_id: user_ids.join('_'),
								type: 1,
								content_type: 4,
								title: '关于《' + this.detail.project_name + '》邀请加入项目的消息'
							});
						})

					}

				}
			},

			async project_manage_state(newer, older) {
				if (newer.id != older.id) {
					this.detail.responsible = newer.id;
					this.detail.responsible_name = newer.username;
					let res = await this.$api.user_api.addResponsible({
						project_id: this.id,
						user_id: newer.id
					})
					if (res.data.code == 200) {						
						if (this.pro_user_id.indexOf(newer.id) == -1) {
							this.pro_user_id.push(newer.id);
						}

						console.log('this.pro_user_id', this.pro_user_id)
						// 项目经理更新 变更负责人
						let d_res = await this.$api.user_api.deldirector({
							project_id: this.id
						})
						if (d_res.data.code == 200) {
							this.detail.director = '';
							this.detail.director_name = '';
						}

						// 发送消息 项目经理
						let sp_res = await this.$api.user_api.addMsg({
							project_id: this.id,
							task_id: '',
							content: '【' + this.detail.approver_name + '】指派【' + newer.username + '】为《' + this.detail.project_name + '》项目经理，请尽快成立项目小组开展实施项目！',
							user_id: newer.id,
							type: 1,
							content_type: 3,
							title: '指派您为《' + this.detail.project_name + '》的项目经理的通知'
						});


						// // 更新项目状态
						// let update_status = await this.$api.project_api.updateProjectStatus({
						// 	id: this.id,
						// 	status: '3',
						// 	content: '指派给'+this.sp.project_manage.username+'跟进',
						// })
						// console.log(update_status)
						this.$store.commit('PROJECT_LIST_UPDATE', 1);
					}
				}
			},

			task_list_update(newer, older) {
				if (newer != older) {
					this.loadingState.default = true;
					this.task = [];
					this.getTaskList();
					this.getTaskRate();
				}
			},

			promonback_list_update(newer, older) {
				if (newer != older) {
					this.loadingState.default = true;
					this.promonbackList = [];
					this.getPromonbackList();
				}
			},

			status_update(newer, older) {
				if (newer != older) {
					this.getDetail();
				}
			}
		},
	}
</script>

<style lang="less" scoped>
	.body,
	.page {
		height: 100%;
	}
	.sp-btn-bar{
		display: flex;
		justify-content: space-between;
		.btn{
			width: 48%;
		}
		.cancle-btn{
			background: #f00;
		}
	}
	.mail-info{
		padding: 20rpx;
		background: #fff;
	}
	.fail-tips {
		background: #ffd9c2;
		padding: 20rpx;
		font-size: 28rpx;
		color: #ff5500;
	}

	.finish-btn {
		width: 90%;
		margin: 0 auto;
		background: #ff9600;
		padding: 20rpx 10rpx;
		border-radius: 10rpx;
		font-size: 28rpx;
		color: #fff;
		text-align: center;
	}
	.check-report-btn{
		display: flex;
		margin-left: 50rpx;
	}
	.info-wrap {
		position: relative;
		overflow: hidden;
		background: #09f;

		.info-bg {
			position: absolute;
			left: 0;
			top: 0;
		}

		.content {
			position: relative;
			width: 100%;
			height: 100%;
		}

		.pro-status {
			position: absolute;
			right: 0;
			top: 25rpx;
			display: flex;
			margin-right: 30rpx;
			color: #fff;
			font-size: 28rpx;

			.btn {
				padding: 2rpx 10rpx;
				border-radius: 10rpx;
				font-size: 28rpx;
				color: #fff;
			}

			.orange {
				background: #ff9600;
			}

			.blue {
				background: #09f;
			}

			.red {
				background: #f00;
			}
		}

		.finish-icon {
			position: absolute;
			right: 0;
			top: 0;
			width: 180rpx;

			image {
				width: 100%;
			}
		}

		.title {
			max-width: 75%;
			padding: 20rpx 30rpx 20rpx;
			font-size: 32rpx;
			font-weight: bold;
			color: #fff;
		}

		.desc {
			padding: 0 30rpx 20rpx;
			font-size: 28rpx;
			color: #f5f5f5;
		}

		.progress-bar {
			display: flex;
			align-items: center;
			margin: 0 30rpx 20rpx;

			.progress {
				position: relative;
				height: 15rpx;
				width: 80%;
				margin-right: 20rpx;
				border-radius: 15rpx;
				background: #ccc;

				.kd {
					position: absolute;
					left: 0;
					top: 0;
					height: 15rpx;
					border-radius: 15rpx;
					background: #fff;
				}
			}

			.progress-data {
				font-size: 28rpx;
				color: #fff;
			}
		}

		.ft {
			display: flex;
			align-items: center;
			padding: 0 30rpx 20rpx;

			.item {
				color: #fff;
				font-size: 28rpx;
			}

			.status {
				display: flex;
				align-items: center;
				margin-right: 30rpx;
				color: #fff;
				font-size: 28rpx;

				.val {
					display: flex;
					align-items: center;
				}

				.btn {
					padding: 2rpx 10rpx;
					border-radius: 10rpx;
					font-size: 28rpx;
					color: #fff;
				}

				.orange {
					background: #ff9600;
				}

				.blue {
					background: #09f;
				}

				.red {
					background: #f00;
				}
			}

			.btn {
				padding: 8rpx 20rpx;
				border-radius: 8rpx;
			}

			.orange {
				background: #ff9600;
				color: #fff;
				font-size: 28rpx;
			}
		}
	}

	.handle-btn-wrap {
		display: flex;
		justify-content: space-between;
		padding: 0 30rpx;

		.left {
			display: flex;

			.btn {
				margin-right: 20rpx;
			}
		}

		.btn {
			padding: 2rpx 10rpx;
			margin-bottom: 20rpx;
			border-radius: 10rpx;
			color: #fff;
			font-size: 28rpx;
		}

		.yello {
			background: #00ff00;
		}

		.green {
			background: #00aa00;
		}

		.orange {
			background: #ff9600;
		}

		.grey {
			background: #ccc;
		}

		.red {
			background: #f00;
		}
	}

	.info-tab {
		width: 100%;
		overflow: hidden;
		height: 90rpx;
		background: #fff;
		border-bottom: 1rpx solid #eee;
	}

	.tab-content {
		padding: 0 0;

		.empty-btn {
			width: 40%;
			height: 70rpx;
			line-height: 70rpx;
			margin: 0 auto;
			background: #09f;
			border-radius: 10rpx;
			font-size: 28rpx;
			color: #fff;
			text-align: center;
		}
	}

	.detail {
		padding: 20rpx 0 0;

		.item {
			padding: 20rpx 0 0;
			background: #fff;
			margin-bottom: 20rpx;
		}

		.hd-title {
			margin: 20rpx;

			.title {
				position: relative;
				height: 28rpx;
				line-height: 28rpx;
				font-size: 30rpx;
				font-weight: bold;
				text-align: center;

				&::before,
				&::after {
					position: absolute;
					top: 50%;
					content: '';
					width: 120rpx;
					border-top: 1rpx solid #ddd;
				}

				&::after {
					right: 120rpx;
				}

				&::before {
					left: 120rpx;
				}
			}

		}

		.detail-content {
			padding: 0 20rpx;

			.subitem {
				display: flex;
				margin-bottom: 20rpx;

				.label {
					width: 150rpx;
					font-size: 28rpx;
					color: #333;
				}

				.val {
					font-size: 28rpx;
					color: #333;
				}
			}
		}
	}

	.download-wrap {
		padding: 30rpx 0;

		.list {
			padding: 0 20rpx;

			.item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 20rpx;
				margin-bottom: 10rpx;
				background: #fff;
				border-radius: 10rpx;

				.left {
					display: flex;
					align-items: center;
					flex-wrap: wrap;
					max-width: 80%;
				}

				.file-icon {
					width: 40rpx;
					margin-right: 20rpx;
					flex-shrink: 0;
				}

				.name {
					max-width: 85%;

					.title {
						font-size: 28rpx;
					}

					.info {
						display: flex;
					}

					text {
						font-size: 24rpx;
						margin-right: 30rpx;
						color: #999;
					}
				}

				.download-icon {
					flex-shrink: 0;
					width: 60rpx;
				}
			}
		}
	}

	.upload-area {
		padding: 20rpx;
		background: #fff;

		.icon {
			margin-bottom: 40rpx;
			text-align: center;
			font-size: 160rpx;
			color: #0099ff;
		}

		.btn {
			width: 50%;
			height: 70rpx;
			line-height: 70rpx;
			margin: 0 auto;
			background: #09f;
			border-radius: 8rpx;
			color: #fff;
			font-size: 30rpx;
			text-align: center;

		}
	}

	.task-list {
		padding: 20rpx 0;

		.item {
			margin: 0 0 20rpx;
			padding: 0 20rpx;
			background: #fff;

			.title {
				display: flex;
				justify-content: space-between;
				border-bottom: 1rpx solid #eee;
				padding: 15rpx 0;

				.name {
					max-width: 80%;
					font-size: 28rpx;
				}

				.status {
					flex-shrink: 0;
					font-size: 26rpx;
					color: #09f;
				}
			}

			.content {
				padding: 30rpx 0;

				.row-2 {
					display: flex;
					justify-content: space-between;
				}

				.zp-btn {
					padding: 0 5rpx;
					background: #ff9600;
					border-radius: 8rpx;
					color: #fff;
					font-size: 28rpx;
				}
			}

			.subitem {
				display: flex;
				margin-bottom: 20rpx;
				font-size: 28rpx;

				.label {
					flex-shrink: 0;
					width: 120rpx;
					margin-right: 20rpx;
					color: #666;
				}

				.val {
					.level {
						border-radius: 8rpx;
						padding: 0 8rpx;
					}

					.l-1 {
						border: 1rpx solid #09f;
						color: #09f;
					}

					.l-2 {
						background-color: #fef0f0;
						border: 1rpx solid #fde2e2;
						color: #f56c6c;
					}

					.l-3 {
						background-color: #f0f9eb;
						border: 1rpx solid #e1f3d8;
						color: #67c23a;
					}
				}
			}

			.btn-wrap {
				display: flex;
				justify-content: space-between;
				border-top: 1rpx solid #eee;
				padding: 15rpx 0 0;

				.left {
					display: flex;

					.btn {
						margin-right: 20rpx;
					}
				}

				.right {
					display: flex;

					.btn {
						margin-left: 20rpx;
					}
				}

				.btn {
					border-radius: 10rpx;
					padding: 4rpx 10rpx;
					color: #fff;
					font-size: 26rpx;
				}

				.blue {
					background: #09f;
				}

				.orange {
					background: #ff9600;
				}

				.red {
					background: #f00;
				}

				.yello {
					background: #00ff00;
				}

				.green {
					background: #00aa00;
				}
			}

		}
	}

	.back-money-play {
		padding: 20rpx 0;

		.item {
			margin: 0 0 20rpx;
			padding: 0 20rpx;
			background: #fff;

			.title {
				display: flex;
				justify-content: space-between;
				border-bottom: 1rpx solid #eee;
				padding: 15rpx 0;

				.name {
					font-size: 28rpx;
					font-weight: bold;
				}

				.status {
					font-size: 26rpx;
					color: #09f;
				}
			}

			.content {
				padding: 30rpx 0 20rpx;

				.row-2 {
					display: flex;
					justify-content: space-between;
				}
			}

			.subitem {
				display: flex;
				margin-bottom: 20rpx;
				font-size: 28rpx;

				.label {
					flex-shrink: 0;
					width: 120rpx;
					margin-right: 20rpx;
					color: #666;
				}

				.val {
					.level {
						border-radius: 8rpx;
						padding: 0 8rpx;
					}
				}
			}

			.btn-wrap {
				display: flex;
				justify-content: flex-end;
				border-top: 1rpx solid #eee;
				padding: 15rpx 0 0;

				.btn {
					margin-left: 20rpx;
					border-radius: 10rpx;
					padding: 4rpx 10rpx;
					color: #fff;
					font-size: 26rpx;
				}

				.blue {
					background: #09f;
				}

				.orange {
					background: #ff9600;
				}

				.red {
					background: #f00;
				}
			}

		}
	}

	.add-btn {
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		right: 20rpx;
		bottom: 50rpx;
		width: 100rpx;
		height: 100rpx;
		text-align: center;
		background: #09f;
		box-shadow: 0 0 10rpx #09f;
		border-radius: 50%;
		color: #fff;
		font-size: 28rpx;

		.text {
			width: 70rpx;
		}
	}

	.project_user {
		display: flex;
		background: #fff;
		margin: 20rpx 0;
		padding: 20rpx 20rpx 0;
		color: #fff;
		font-size: 28rpx;

		.label {
			flex-shrink: 0;
			margin-right: 20rpx;
			font-size: 28rpx;
			color: #333;
		}

		.list {
			display: flex;
			flex-wrap: wrap;
			flex-grow: 2;
			max-width: 90%;

			.item {
				position: relative;
				width: 70rpx;
				height: 70rpx;
				line-height: 70rpx;
				margin: 0 20rpx 20rpx 0;
				background: #09f;
				border-radius: 10rpx;
				color: #fff;
				text-align: center;

				.del {
					position: absolute;
					right: 0;
					top: -34rpx;
					width: 24rpx;
					height: 24rpx;
					color: #f00;
				}
			}

			.add {
				width: 70rpx;
				height: 70rpx;

				image {
					width: 100%;
				}
			}
		}

	}

	.download-tips {
		position: fixed;
		left: 2%;
		bottom: 30rpx;
		width: 88%;
		padding: 20rpx 4%;
		background: #fff;
		border-radius: 10rpx;
		font-size: 28rpx;

	}

	.chat-btn {
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin: 0 20rpx 20rpx;

		navigator {
			padding: 5rpx 15rpx;
			background: #ff9600;
			border-radius: 10rpx;
			color: #fff;
			font-size: 30rpx;
		}
	}
</style>